package com.bkitclub.mobiledevcamp.horseword;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;

import com.bkitclub.mobiledevcamp.horseword.customGUI.CustomButton;
import com.bkitclub.mobiledevcamp.horseword.util.Const;
import com.bkitclub.mobiledevcamp.horseword.util.ResourceManager;
import com.bkitclub.mobiledevcamp.horseword.util.Utils;

public class MainScreen extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	requestWindowFeature(Window.FEATURE_NO_TITLE);
    	this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                WindowManager.LayoutParams.FLAG_FULLSCREEN );
        super.onCreate(savedInstanceState);
        
        Utils.loadScreenSize(this);
        setContentView(R.layout.home_screen);
        createLayout();
    }
    private void createLayout(){
    	FrameLayout mainLayout = (FrameLayout) findViewById(R.id.home_screen_parent);
    	CustomButton btnPlay = new CustomButton(this);
    	CustomButton btnExit = new CustomButton(this);
    	
    	btnPlay.initResource(ResourceManager.getInstance().getImage(this, "home/play.png"));
    	btnExit.initResource(ResourceManager.getInstance().getImage(this, "home/exit.png"));
    	
    	FrameLayout.LayoutParams btnPlayLp = new FrameLayout.LayoutParams(btnPlay.getResourceWidth(), btnPlay.getResourceHeight());
    	FrameLayout.LayoutParams btnExitLp = new FrameLayout.LayoutParams(btnExit.getResourceWidth(), btnExit.getResourceHeight());
    	mainLayout.setBackgroundDrawable(new BitmapDrawable(ResourceManager.getInstance().getImage(this, "home/home.png")));
    	Const.setPositionBtnExit(btnExitLp);
    	Const.setPositionBtnPlay(btnPlayLp);
    	btnExitLp.gravity = Gravity.TOP | Gravity.LEFT;
    	btnPlayLp.gravity = Gravity.TOP | Gravity.LEFT;
    	btnPlay.setLayoutParams(btnPlayLp);
    	btnExit.setLayoutParams(btnExitLp);
    	
    	btnExit.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				System.exit(0);
			}
		});
    	btnPlay.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(MainScreen.this,PlayActivity.class);
				startActivity(intent);
			}
		});
    	mainLayout.addView(btnPlay);
    	mainLayout.addView(btnExit);
    }
}